<template>
  <div class="app-container">
    <el-tabs v-model="activeName" @tab-click="handleClick">
      <el-tab-pane label="我的客户" name="mycus">
        <CusList ref="mycus" category="IC" list_type="1" />
      </el-tab-pane>
      <el-tab-pane label="下属客户" name="subcus">
        <CusList ref="subcus" category="IC" list_type="2" />
      </el-tab-pane>
      <el-tab-pane label="部门客户" name="deptcus">
        <CusList ref="deptcus" category="IC" list_type="0" />
      </el-tab-pane>
      <el-tab-pane v-if="isAll" label="全部客户" name="allcus">
        <CusList ref="allcus" category="IC" />
      </el-tab-pane>
    </el-tabs>
  </div>
</template>

<script>
import CusList from "../components/cuslist.vue";
import { getRole } from "@/utils/auth";
export default {
  components: {
    CusList
  },
  data() {
    return {
      activeName: "mycus",
      isAll: false
    };
  },
  created() {
    this.isAll = getRole().some(item => item.admin);
  },
  methods: {
    handleClick(tab) {
      this.$refs[tab.name].getList();
    }
  }
};
</script>

<style lang="scss" scoped>

</style>
